<?php

namespace App\Http\Controllers;

use Dingo\Api\Routing\Helpers;
use Illuminate\Http\Request;
use App\Http\Controllers\Business\App\Auth\AppAuth;

class ApiController extends Controller
{
    // 接口帮助调用
    use Helpers;

    // 请求
    protected $request;

    // 登录用户id
    protected $userId;

    public function __construct(Request $request)
    {
        $this->request = $request;
        if($this->request->get('token'))
        {
            $this->userId=AppAuth::tokenGetUserId($this->request->get('token'));
        }
    }

    //失败返回
    public function responseError($message)
    {
        return $this->response->array([
            'status'=>'failed',
            'message'=>$message
        ]);
    }
    public function responseSuccessData($data)
    {
        return $this->response->array([
            'status'=>'success',
            'data'=>$data
        ]);
    }
    public function responseSuccessMessage($message)
    {
        return $this->response->array([
            'status'=>'success',
            'message'=>$message
        ]);
    }
}
